package com.training.java.core.collections.one;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class MapDemo {

	public static void main(String[] args) {

		Map<String, String> directory = new HashMap<>();
		
		directory.put("Sushmita", "1238987377");
		directory.put("Ronnie", "1238987377");
		directory.put("Reenu", "1238987377");
		
		directory.put("Henry", "1238987377");

		// Read Reenu's phone number
		String reenuPhoneNumber = directory.get("Reenu");
		System.out.println("Reenu phone number =" + reenuPhoneNumber);

		// second approach
		Set<String> keys = directory.keySet();
		
		for(String key : keys){
			System.out.println("Key = " + key);
			String value = directory.get(key);
			System.out.println("Vale =" + value);
		}
		
		Set<Entry<String, String>> entries = directory.entrySet();

		for (Entry<String, String> entry : entries) {
			System.out.println("Key = " + entry.getKey());
			System.out.println("Value = " + entry.getValue());
		}

	}

}
